import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import HomeView from '../views/home/index.vue'
import KindView from '../views/kind/index.vue'
import CartView from '../views/cart/index.vue'
import UserView from '../views/user/index.vue'


const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    // redirect 设置路由的重定向，修改路由的路径
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    meta: {
      // 定义路由的元信息，可以判断 hidden 来决定是否显示 footer
      hidden: true
    }
  }, {
    path: '/kind',
    name: 'kind',
    component: KindView,
    meta: {
      // 定义路由的元信息，可以判断 hidden 来决定是否显示 footer
      hidden: true
    }
  },
  {
    path: '/cart',
    name: 'cart',
    component: CartView,
    meta: {
      // 定义路由的元信息，可以判断 hidden 来决定是否显示 footer
      hidden: true
    }
  },
  {
    path: '/user',
    name: 'user',
    component: UserView,
    meta: {
      // 定义路由的元信息，可以判断 hidden 来决定是否显示 footer
      hidden: true
    }
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/login/index.vue'),

  },
  {
    path: '/register',
    name: 'register',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/register/index.vue'),
    redirect: '/register/step1',
    children: [
      {
        path: 'step1',
        name: 'step1',
        component: () => import('../views/register/step1.vue'),
      },
      {
        path: 'step2',
        name: 'step2',
        component: () => import('../views/register/step2.vue'),
      },
      {
        path: 'step3',
        name: 'step3',
        component: () => import('../views/register/step3.vue'),
      }
    ]

  }
]

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes
})


export default router
